package com.cadre.system;

import com.alibaba.fastjson.JSONArray;
import com.cadre.common.utils.oldutil.DateUtil;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

/* loaded from: SearchHelper.class */
public class SearchHelper {
    private static final String AGE = "6";
    private static final String NAME = "2";
    private static final String NV = "3";
    private static final String ZHIWU = "4";
    private static final String SHAOSHUMINGZU = "7";
    private static final String FEIZHONGGONG = "10";
    private static final String EDUCATION = "118";
    private static final String XUELI = "30";
    private static final String SHUXILINGYU = "77";
    private static final String GONGZUOJINGLI = "53";
    private static final String ZHIJI = "13";
    private static final String ZHIJI1 = "131";
    private static final String GANBULEIBIE = "22";
    private static final String RENXIANZHIJINIANXIAN = "48";
    private static final String RENXIANZHIJINIANXIAN_FULL = "481";
    private static final String RENXIANZHIJINIANXIAN_NOTFULL = "482";
    private static final String RENZHINIANXIAN = "49";
    private static final String RENZHINIANXIAN_FULL = "491";
    private static final String RENZHINIANXIAN_NOTFULL = "492";
    private static final String RENZHIWUCENGCI = "500";
    private static final String RENZHIWUCENGCI_FULL = "501";
    private static final String RENZHIWUCENGCI_NOTFULL = "502";
    private static final String ZHIWULEIBIE = "50";
    private static final String ZHUANYEJISHUZHIWUXILIE = "51";
    private static final String ZHUANYEJISHUZHIWUDENGJI = "52";
    private static final String ZHUANYELEIBIE = "36";
    private static final String RESUME = "999";
    private static final String UNITID = "998";
    private static final String BENGINBIRTHDAY = "997";
    private static final String ENDBIRTHDAY = "996";
    private static final String A0180Start = "991";
    private static final String A0180End = "990";
    private static final String A0185Start = "995";
    private static final String A0185End = "994";
    private static final String A0142Start = "993";
    private static final String A0142End = "992";
    private static final String KEY = "tagId";
    protected static final String VALUE = "valueString";
    private static final String A1940S = "74";
    private static Map<String, String> basemap = new HashMap();

    static {
        basemap.put("研究生教育", "1");
        basemap.put("研究生", "1");
        basemap.put("研究生以下", "2,3,4,5,6,7,8,null");
        basemap.put("本科以上", "1");
        basemap.put("本科教育", NAME);
        basemap.put("本科", NAME);
        basemap.put("专科教育", NV);
        basemap.put("专科", NV);
        basemap.put("中专教育", ZHIWU);
        basemap.put("中专", ZHIWU);
        basemap.put("其他", "5,6,7,8");
        basemap.put("哲学", "01");
        basemap.put("经济学", "02");
        basemap.put("法学", "03");
        basemap.put("教育学", "04");
        basemap.put("文学", "05");
        basemap.put("历史学", "06");
        basemap.put("理学", "07");
        basemap.put("工学", "08");
        basemap.put("农学", "09");
        basemap.put("医学", FEIZHONGGONG);
        basemap.put("管理学", "12");
        basemap.put("艺术学", ZHIJI);
    }

    public static Map<String, Object> convertQueryParam(Map<String, Object> soureMap, Map<String, Object> destMap) {
        String key = String.valueOf(soureMap.get(KEY));
        JSONArray values = (JSONArray) soureMap.get(VALUE);
        values.removeAll(Collections.singleton(null));
        if (key.equals(GANBULEIBIE)) {
            List<String> a0181s = new ArrayList<>();
            for (int i = 0; i < values.size(); i++) {
                a0181s.add(values.get(i).toString());
            }
            destMap.put("a0181s", a0181s);
            destMap.put("a0181flag", soureMap.get("flag").toString());
            return destMap;
        } else if (key.equals(ZHIJI)) {
            List<String> a0179s = new ArrayList<>();
            for (int i2 = 0; i2 < values.size(); i2++) {
                a0179s.add(values.get(i2).toString());
            }
            destMap.put("a0179s", a0179s);
            return destMap;
        } else if (key.equals(ZHIJI1)) {
            List<String> a0198s = new ArrayList<>();
            for (int i3 = 0; i3 < values.size(); i3++) {
                a0198s.add(values.get(i3).toString());
            }
            destMap.put("a0198s", a0198s);
            return destMap;
        } else if (key.equals(ZHIWU)) {
            List<String> a0183s = new ArrayList<>();
            for (int i4 = 0; i4 < values.size(); i4++) {
                a0183s.add(values.get(i4).toString());
            }
            destMap.put("a0183s", a0183s);
            return destMap;
        } else if (key.equals(UNITID)) {
            List<String> unitids = new ArrayList<>();
            for (int i5 = 0; i5 < values.size(); i5++) {
                unitids.add(values.get(i5).toString());
            }
            destMap.put("unitParam", unitids);
            return destMap;
        } else if (key.equals(GONGZUOJINGLI)) {
            List<String> a0177As = new ArrayList<>();
            for (int i6 = 0; i6 < values.size(); i6++) {
                if (values.get(i6).toString().equals("乡镇街道党政正职")) {
                    a0177As.add("乡镇（街道）党政正职");
                } else if (values.get(i6).toString().equals("乡镇街道党政副职")) {
                    a0177As.add("乡镇（街道）党政副职");
                } else {
                    a0177As.add(values.get(i6).toString());
                }
            }
            destMap.put("a0177As", a0177As);
            destMap.put("a0177AFlag", soureMap.get("flag").toString());
            return destMap;
        } else if (key.equals(ZHUANYELEIBIE)) {
            if (!soureMap.get("flag").toString().equals("1") || values.size() <= 1) {
                destMap.put("a0410", basemap.get(values.get(0).toString()));
                return destMap;
            }
            destMap.put("errorParam", "errorParam");
            return destMap;
        } else if (key.equals(SHUXILINGYU)) {
            destMap.put("a0176", values);
            destMap.put("a0176Flag", soureMap.get("flag").toString());
            return destMap;
        } else if (key.equals(ZHIWULEIBIE)) {
            if (values.size() > 1) {
                destMap.put("lingdaozhiwu", "错误参数");
            } else {
                destMap.put("lingdaozhiwu", values.get(0).toString());
            }
            return destMap;
        } else if (key.equals(AGE) && values.size() > 0) {
            String ageSql = "( ";
            int size = values.size();
            for (int i7 = 0; i7 < size; i7++) {
                String[] split = ((String) values.get(i7)).split("-");
                ageSql = ageSql + "( TRUNC(months_between(sysdate, A0106)/12) >= " + split[0] + " and TRUNC(months_between(sysdate, A0106)/12) < (" + (Integer.valueOf(split[1]).intValue() + 1) + "))";
                if (size > 1 && i7 < size - 1) {
                    ageSql = ageSql + " OR ";
                }
            }
            destMap.put("ageSql", ageSql + " )");
            return destMap;
        } else if (key.equals(EDUCATION) && values.size() > 0) {
            destMap.put("a0449", "1");
            ArrayList<String> list = Lists.newArrayList();
            Iterator it = values.iterator();
            while (it.hasNext()) {
                String s = basemap.get(it.next());
                if (StringUtils.isNotBlank(s)) {
                    list.add(s);
                }
            }
            destMap.put("a0460", StringUtils.join(list, ","));
            return destMap;
        } else if (!key.equals(XUELI) || values.size() <= 0) {
            if (key.equals(NV) && values.size() > 0) {
                destMap.put("nsfFlag", soureMap.get("flag").toString());
            }
            if (key.equals(SHAOSHUMINGZU) && values.size() > 0) {
                destMap.put("nsfFlag", soureMap.get("flag").toString());
            }
            if (key.equals(FEIZHONGGONG) && values.size() > 0) {
                destMap.put("nsfFlag", soureMap.get("flag").toString());
            }
            if (key.equals(A1940S)) {
                List<String> a1940s = new ArrayList<>();
                if (values.size() != 0) {
                    if (values.size() != 1) {
                        String sql = " and (";
                        for (int i8 = 0; i8 < values.size(); i8++) {
                            values.get(i8).toString();
                            if (i8 == 0) {
                                if ("领导职务".equals(values.get(i8).toString())) {
                                    sql = sql + " a01.flowid in (select distinct personid from a19 where a1940 = 1)";
                                } else if ("非领导职务".equals(values.get(i8).toString())) {
                                    sql = sql + " a01.flowid in (select distinct personid from a19 where personid not in (select distinct personid from a19 where a1940 = 1))";
                                } else {
                                    sql = sql + "";
                                }
                            } else if ("领导职务".equals(values.get(i8).toString())) {
                                sql = sql + " or a01.flowid in (select distinct personid from a19 where a1940 = 1)";
                            } else if ("非领导职务".equals(values.get(i8).toString())) {
                                sql = sql + " or a01.flowid in (select distinct personid from a19 where personid not in (select distinct personid from a19 where a1940 = 1))";
                            } else {
                                sql = sql + "";
                            }
                        }
                        a1940s.add(sql + ")");
                    } else if ("领导职务".equals(values.get(0).toString())) {
                        a1940s.add(" and a01.flowid in (select distinct personid from a19 where a1940 = 1)");
                    } else if ("非领导职务".equals(values.get(0).toString())) {
                        a1940s.add(" and a01.flowid in (select distinct personid from a19 where personid not in (select distinct personid from a19 where a1940 = 1))");
                    } else {
                        a1940s.add("");
                    }
                }
                destMap.put("a1940s", a1940s);
                return destMap;
            } else if (values.size() > 1) {
                destMap.put("errorParam", "errorParam");
                return destMap;
            } else {
                String value = String.valueOf(values.get(0));
                char c = 65535;
                switch (key.hashCode()) {
                    case 50:
                        if (key.equals(NAME)) {
                            c = 3;
                            break;
                        }
                        break;
                    case 51:
                        if (key.equals(NV)) {
                            c = 0;
                            break;
                        }
                        break;
                    case 55:
                        if (key.equals(SHAOSHUMINGZU)) {
                            c = 1;
                            break;
                        }
                        break;
                    case 1567:
                        if (key.equals(FEIZHONGGONG)) {
                            c = 2;
                            break;
                        }
                        break;
                    case 1668:
                        if (key.equals(RENXIANZHIJINIANXIAN)) {
                            c = 7;
                            break;
                        }
                        break;
                    case 1669:
                        if (key.equals(RENZHINIANXIAN)) {
                            c = '\n';
                            break;
                        }
                        break;
                    case 1692:
                        if (key.equals(ZHUANYEJISHUZHIWUXILIE)) {
                            c = 16;
                            break;
                        }
                        break;
                    case 1693:
                        if (key.equals(ZHUANYEJISHUZHIWUDENGJI)) {
                            c = 17;
                            break;
                        }
                        break;
                    case 51757:
                        if (key.equals(RENXIANZHIJINIANXIAN_FULL)) {
                            c = '\b';
                            break;
                        }
                        break;
                    case 51758:
                        if (key.equals(RENXIANZHIJINIANXIAN_NOTFULL)) {
                            c = '\t';
                            break;
                        }
                        break;
                    case 51788:
                        if (key.equals(RENZHINIANXIAN_FULL)) {
                            c = 11;
                            break;
                        }
                        break;
                    case 51789:
                        if (key.equals(RENZHINIANXIAN_NOTFULL)) {
                            c = '\f';
                            break;
                        }
                        break;
                    case 52469:
                        if (key.equals(RENZHIWUCENGCI)) {
                            c = '\r';
                            break;
                        }
                        break;
                    case 52470:
                        if (key.equals(RENZHIWUCENGCI_FULL)) {
                            c = 14;
                            break;
                        }
                        break;
                    case 52471:
                        if (key.equals(RENZHIWUCENGCI_NOTFULL)) {
                            c = 15;
                            break;
                        }
                        break;
                    case 56592:
                        if (key.equals(A0180End)) {
                            c = 19;
                            break;
                        }
                        break;
                    case 56593:
                        if (key.equals(A0180Start)) {
                            c = 18;
                            break;
                        }
                        break;
                    case 56594:
                        if (key.equals(A0142End)) {
                            c = 23;
                            break;
                        }
                        break;
                    case 56595:
                        if (key.equals(A0142Start)) {
                            c = 22;
                            break;
                        }
                        break;
                    case 56596:
                        if (key.equals(A0185End)) {
                            c = 21;
                            break;
                        }
                        break;
                    case 56597:
                        if (key.equals(A0185Start)) {
                            c = 20;
                            break;
                        }
                        break;
                    case 56598:
                        if (key.equals(ENDBIRTHDAY)) {
                            c = 5;
                            break;
                        }
                        break;
                    case 56599:
                        if (key.equals(BENGINBIRTHDAY)) {
                            c = 4;
                            break;
                        }
                        break;
                    case 56601:
                        if (key.equals(RESUME)) {
                            c = 6;
                            break;
                        }
                        break;
                }
                switch (c) {
                    case 0:
                        destMap.put("a0105", value);
                        break;
                    case 1:
                        destMap.put("a0130", "少数民族");
                        break;
                    case DateUtil.SUB_MONTH:
                        if (value.equals("中共党员")) {
                            destMap.put("a0184", "中共党员");
                        }
                        if (value.equals("非中共党员") || value.equals("非中共")) {
                            destMap.put("a0184", "非中共党员");
                            break;
                        }
                        break;
                    case 3:
                        destMap.put("a0101", value);
                        break;
                    case 4:
                        destMap.put("beginBirthday", value);
                        break;
                    case DateUtil.SUB_DAY:
                        destMap.put("endBirthday", value);
                        break;
                    case 6:
                        destMap.put("a0177b", value);
                        break;
                    case 7:
                        String a0142End = null;
                        if (!"".equals(value) && !value.isEmpty()) {
                            if (!value.contains("-")) {
                                if (value != null && !value.isEmpty() && value != null && !value.isEmpty() && value.equals(value)) {
                                    destMap.put("A0142Start1", value);
                                    destMap.put("A0142End1", String.valueOf(Integer.parseInt(value) + 1));
                                    break;
                                }
                            } else {
                                String[] valuesTemp = value.split("-");
                                String a0142Start = valuesTemp[0];
                                try {
                                    a0142End = valuesTemp[1];
                                } catch (Exception e) {
                                }
                                if (a0142Start != null && !a0142Start.isEmpty() && a0142End != null && !a0142End.isEmpty()) {
                                    if (a0142Start.equals(a0142End)) {
                                        destMap.put("A0142Start1", a0142Start);
                                        destMap.put("A0142End1", String.valueOf(Integer.parseInt(a0142End) + 1));
                                        break;
                                    } else {
                                        destMap.put("A0142Start", a0142Start);
                                        destMap.put("A0142End", a0142End);
                                        break;
                                    }
                                } else {
                                    destMap.put("A0142Start", a0142Start);
                                    destMap.put("A0142End", a0142End);
                                    break;
                                }
                            }
                        }
                        break;
                    case '\b':
                        destMap.put("a0142full", value);
                        break;
                    case '\t':
                        destMap.put("a0142notfull", value);
                        break;
                    case DateUtil.SUB_HOUR:
                        String a0185End = null;
                        if (!"".equals(value) && !value.isEmpty()) {
                            if (!value.contains("-")) {
                                if (value != null && !value.isEmpty() && value != null && !value.isEmpty() && value.equals(value)) {
                                    destMap.put("A0185Start1", value);
                                    destMap.put("A0185End1", String.valueOf(Integer.parseInt(value) + 1));
                                    break;
                                }
                            } else {
                                String[] valuesTemp2 = value.split("-");
                                String a0185Start = valuesTemp2[0];
                                try {
                                    a0185End = valuesTemp2[1];
                                } catch (Exception e2) {
                                }
                                if (a0185Start != null && !a0185Start.isEmpty() && a0185End != null && !a0185End.isEmpty()) {
                                    if (a0185Start.equals(a0185End)) {
                                        destMap.put("A0185Start1", a0185Start);
                                        destMap.put("A0185End1", String.valueOf(Integer.parseInt(a0185End) + 1));
                                        break;
                                    } else {
                                        destMap.put("A0185Start", a0185Start);
                                        destMap.put("A0185End", a0185End);
                                        break;
                                    }
                                } else {
                                    destMap.put("A0185Start", a0185Start);
                                    destMap.put("A0185End", a0185End);
                                    break;
                                }
                            }
                        }
                        break;
                    case 11:
                        destMap.put("a0185full", value);
                        break;
                    case DateUtil.SUB_MINUTE:
                        destMap.put("a0185notfull", value);
                        break;
                    case DateUtil.SUB_SECOND:
                        String a0180End = null;
                        if (!"".equals(value) && !value.isEmpty()) {
                            if (!value.contains("-")) {
                                if (value != null && !value.isEmpty() && value != null && !value.isEmpty() && value.equals(value)) {
                                    destMap.put("A0180Start1", value);
                                    destMap.put("A0180End1", String.valueOf(Integer.parseInt(value) + 1));
                                    break;
                                }
                            } else {
                                String[] valuesTemp3 = value.split("-");
                                String a0180Start = valuesTemp3[0];
                                try {
                                    a0180End = valuesTemp3[1];
                                } catch (Exception e3) {
                                }
                                if (a0180Start != null && !a0180Start.isEmpty() && a0180End != null && !a0180End.isEmpty()) {
                                    if (a0180Start.equals(a0180End)) {
                                        destMap.put("A0180Start1", a0180Start);
                                        destMap.put("A0180End1", String.valueOf(Integer.parseInt(a0180End) + 1));
                                        break;
                                    } else {
                                        destMap.put("A0180Start", a0180Start);
                                        destMap.put("A0180End", a0180End);
                                        break;
                                    }
                                } else {
                                    destMap.put("A0180Start", a0180Start);
                                    destMap.put("A0180End", a0180End);
                                    break;
                                }
                            }
                        }
                        break;
                    case 14:
                        destMap.put("a0180full", value);
                        break;
                    case 15:
                        destMap.put("a0180notfull", value);
                        break;
                    case 16:
                        destMap.put("a1005", value);
                        break;
                    case 17:
                        destMap.put("a1013", value);
                        break;
                    case 18:
                        destMap.put("a0180Start", value);
                        break;
                    case 19:
                        destMap.put("a0180End", value);
                        break;
                    case 20:
                        destMap.put("a0185Start", value);
                        break;
                    case 21:
                        destMap.put("a0185End", value);
                        break;
                    case 22:
                        destMap.put("a0142Start", value);
                        break;
                    case 23:
                        destMap.put("a0142End", value);
                        break;
                }
                return destMap;
            }
        } else {
            destMap.put("a0449", NAME);
            StringJoiner sj = new StringJoiner(" OR ", "( ", " )");
            for (int i9 = 0; i9 < values.size(); i9++) {
                String valuesString = values.getString(i9);
                if (!StringUtils.isEmpty(valuesString)) {
                    if (valuesString.equals("研究生教育") || valuesString.equals("研究生")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  = 1 )");
                    }
                    if (valuesString.equals("本科教育") || valuesString.equals("本科")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  = 2 )");
                    }
                    if (valuesString.equals("专科教育") || valuesString.equals("专科")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  = 3 )");
                    }
                    if (valuesString.equals("中专教育") || valuesString.equals("中专")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  = 4 )");
                    }
                    if (valuesString.equals("本科以上")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  = 1 )");
                    }
                    if (valuesString.equals("研究生以下")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  not in (1) or SUBSTR(a0460, 1, 1) is null  )");
                    }
                    if (valuesString.equals("其他")) {
                        sj.add(" (SUBSTR(a0460, 1, 1)  not in(1,2,3,4) or SUBSTR(a0460, 1, 1) is null  )");
                    }
                }
            }
            destMap.put("a0460", sj.toString().equals("(  )") ? null : sj.toString());
            return destMap;
        }
    }
}
